package cn.mylearn.staservice.schedule;

import cn.mylearn.staservice.service.StatisticsDailyService;
import cn.mylearn.staservice.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class ScheduledTask {

    @Autowired
    private StatisticsDailyService dailyService;


    //（0/5 * * * * ？）：每隔5秒执行一次
    @Scheduled(cron = "0 0 1 * * ?")//指定cron表达式规则
    public void task01(){
        System.out.println("=========我执行了");
        dailyService.createStatisticsByDay(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
    }
}
